package util

import (
	"crypto/md5"
	"encoding/hex"
)

func MD5String(object interface{}) string {
	switch object.(type) {
	case []byte:
		b := md5.New().Sum(object.([]byte))
		return hex.EncodeToString(b)
	case string:
		b := md5.New().Sum([]byte(object.(string)))
		return hex.EncodeToString(b)
	default:
		b := md5.New().Sum([]byte(JsonEncode(object)))
		return hex.EncodeToString(b)
	}
}
